package com.sanley.coronavirus.dao;

import com.sanley.coronavirus.entity.Notification;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface NotificationDao {

    @Select("select * from notification where isDelete=0")
    List<Notification> queryNotification();

    @Insert("insert into notification (tittle,content,notificationTime,isDelete,userId) values(#{tittle},#{content},#{notificationTime},#{isDelete},#{userId})")
    int addNotification(Notification notification);

    @Update("update notification set tittle=#{tittle} , content=#{content} where id=#{id}")
    int updateNotificationById(Notification notification);

    @Update("update notification set isDelete=1 where id =#{id} ")
    int deleteNotificationById(Integer id);

    @Select("select * from notification where id=#{id} and isDelete=0")
    Notification getNotificationById(int id);

    @Select("select * from notification where isDelete=0 and tittle like concat( '%' , #{tittle}, '%')")
    List<Notification> getNotificationByTittle(String tittle);
}
